import axios from "axios";
import service from "@/config/index";

const TRANSPORT = {
  SEARCH: `${service.serviceTransport}/waybill/search`
};
export default {
  search (params) {
    return axios.post(TRANSPORT.SEARCH, params);
  },
  getDetail (waybillId) {
    return axios.get(`${service.serviceTransport}/waybill/${waybillId}`);
  },
  dispatch (data) {
    return axios.post(`${service.serviceTransport}/waybill/dispatch`, data);
  },
  batchDispatch (data) {
    return axios.post(
      `${service.serviceTransport}/waybill/batch/dispatch`,
      data
    );
  },
  sign (data) {
    return axios.post(`${service.serviceTransport}/waybill/sign`, data);
  },
  receipt (data) {
    return axios.post(`${service.serviceTransport}/waybill/receipt`, data);
  },
  accept (data) {
    return axios.post(`${service.serviceTransport}/waybill/accept`, data);
  },
  // 拒绝接收
  refuse (data) {
    return axios.post(`${service.serviceTransport}/waybill/refuse`, data);
  },
  // 拒绝关单
  rejectClose (data) {
    return axios.post(`${service.serviceTransport}/waybill/rejected/close`, data);
  },
  // 同意关单
  agree (data) {
    return axios.post(`${service.serviceTransport}/waybill/agree/close`, data);
  },
  // 撤销拆单
  cancelSplit (data) {
    return axios.post(`${service.serviceTransport}/waybill/cancel/split`, data);
  },
  // 撤销调度
  recallDispath (data) {
    return axios.post(`${service.serviceTransport}/waybill/cancel/dispatch`, data);
  },
  update (data) {
    return axios.post(`${service.serviceTransport}/waybill/update`, data);
  },
  getDivideWaybillDetail (waybillId) {
    return axios.get(`${service.serviceTransport}/divide/waybill/${waybillId}`);
  },
  // 运输电子回单部门实时状态和定位
  getByDevCode (devCode, positionFlag) {
    return axios.get(`/ere/device/getByDevCode/${devCode}/${positionFlag}`);
  },
  // 订单电子回单部门实时状态和定位
  getOrderPosition (data) {
    return axios.post(`/ere/track/orderPosition`, data);
  },
  // 同步回单照片
  syncPicture (data) {
    return axios.post(`${service.serviceTransport}/waybill/sync/receipt/picture`, data);
  },
  // 同步回单照片
  attachment (data) {
    return axios.post(`${service.serviceTransport}/attachment/search`, data);
  },
  /* 手动更新运单货物跟踪信息 */
  manualRefresh (data) {
    return axios.post(`${service.serviceTransport}/track/refresh`, data);
  },
  waybillSum (data) {
    return axios.post(`${service.serviceTransport}/waybill/sum`, data);
  },
  combineSum (data) {
    return axios.post(`${service.serviceTransport}/combine/sum`, data);
  },
  closeWaybillQuote (data) {
    return axios.post(`${service.serviceTransport}/waybill/close/quote`, data);
  },
  closeCombineQuote (data) {
    return axios.post(`${service.serviceTransport}/combine/close/quote`, data);
  },
  // 提货预约
  submitPickCovenant (data) {
    return axios.post(`${service.serviceTransport}/waybill/pick/covenant`, data);
  },
  confirmPickCovenant (data) {
    return axios.post(`${service.serviceTransport}/waybill/pick/covenant/confirm`, data);
  },
  // 运单货物跟踪-设备信息
  waybillDeviceTrace (waybillId) {
    // return axios.get(`${service.serviceTransport}/track/device`, { params: { ...data } })
    return axios.get(`${service.serviceTransport}/track/waybill/${waybillId}/device`)
  },
  // 运单签收前置
  checkSign (data) {
    return axios.post(`${service.serviceTransport}/waybill/sign/check`, data);
  },
};
